<?php

namespace OPGG\LaravelMcpServer\Server\Request;

use OPGG\LaravelMcpServer\Protocol\Handlers\NotificationHandler;
use OPGG\LaravelMcpServer\Enums\ProcessMessageType;
use OPGG\LaravelMcpServer\Server\MCPServer;
use OPGG\LaravelMcpServer\Data\Requests\InitializeData;
use stdClass;

class InitializedNotificationHandler extends NotificationHandler
{
    protected const HANDLE_METHOD = 'notifications/initialized';
    protected const MESSAGE_TYPE = ProcessMessageType::HTTP;
    protected MCPServer $server;

    public function __construct(MCPServer $server)
    {
        parent::__construct();
        $this->server = $server;
    }

    public function execute(?array $params = null): array|stdClass
    {
        $data = InitializeData::fromArray(data: $params);
        $result = $this->server->initialize(data: $data);

        return $result->toArray();
    }
}